import { useRef, forwardRef, useEffect } from "react";

function App() {
  const buttonRef = useRef(null);
  return (
    <div className="App">
      <Button1 ref={buttonRef}>按钮</Button1>
    </div>
  );
}

const Button1 = forwardRef((props, ref) => {
  useEffect(() => {
    console.log(props, ref);
  });
  return <button className="red" ref={ref} {...props} />;
});

export default App;
